﻿using System;
using System.Drawing;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Text;

namespace user_activity
{
    public partial class devButton : System.Windows.Forms.Panel
    {
        bool m_bHoverMode;
        bool m_bMouseDown;
              
        public devButton()
        {            
            m_SetDefaultState();     
        }
                
        protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
        {
            if(!base.IsAccessible)
                base.OnPaint(e);

            SizeF flSizeText = default(SizeF);
            SolidBrush brushText = default(SolidBrush);
                        
            flSizeText = e.Graphics.MeasureString(base.Tag.ToString(), base.Font);
            brushText = new SolidBrush(Color.FromArgb(254,254,254));
            e.Graphics.DrawString(base.Tag.ToString(), base.Font, brushText, (base.Width / 2) - (flSizeText.Width / 2), (base.Height / 2) - (flSizeText.Height / 2));
                       
            if (m_bHoverMode)
            {
                Pen penBorderOutline = new Pen(Color.FromArgb(30,30,30), 1);
                Pen penBorderInline = new Pen(Color.FromArgb(123,123,123), 1);

                Rectangle rcButtonShapeOutline = new Rectangle(0, 0, base.Width - 1, base.Height - 1);
                Rectangle rcButtonShapeInline = new Rectangle(1, 1, base.Width - 3, base.Height - 3);

                e.Graphics.DrawRectangle(penBorderOutline, rcButtonShapeOutline);
                e.Graphics.DrawRectangle(penBorderInline, rcButtonShapeInline);
            }
            else if (m_bMouseDown)
            {
                Pen penBorderOutline = new Pen(Color.FromArgb(30, 30, 30), 1);
                Pen penBorderInline = new Pen(Color.FromArgb(50,50,50), 1);

                Rectangle rcButtonShapeOutline = new Rectangle(0, 0, base.Width - 1, base.Height - 1);
                Rectangle rcButtonShapeInline = new Rectangle(1, 1, base.Width - 3, base.Height - 3);

                e.Graphics.DrawRectangle(penBorderOutline, rcButtonShapeOutline);
                e.Graphics.DrawRectangle(penBorderInline, rcButtonShapeInline);
            }
            else
            {
                Pen penBorderOutline = new Pen(Color.FromArgb(30, 30, 30), 1);
                Pen penBorderInline = new Pen(Color.FromArgb(107, 107, 107), 1);

                Rectangle rcButtonShapeOutline = new Rectangle(0, 0, base.Width - 1, base.Height - 1);
                Rectangle rcButtonShapeInline = new Rectangle(1, 1, base.Width - 3, base.Height - 3);

                e.Graphics.DrawRectangle(penBorderOutline, rcButtonShapeOutline);
                e.Graphics.DrawRectangle(penBorderInline, rcButtonShapeInline);

            }

            base.OnPaint(e);
        }

        protected override void OnMouseMove(System.Windows.Forms.MouseEventArgs e)
        {
            m_bHoverMode = true;
            if (!m_bMouseDown)
            {
                base.BackColor = Color.FromArgb(94, 94, 94);
            }
            else
            {
                base.BackColor = Color.FromArgb(54,54,54);
            }            
            base.OnMouseMove(e);
        }

        protected override void OnMouseLeave(EventArgs e)
        {
            m_bHoverMode = false;
            base.BackColor = Color.FromArgb(90,90,90);
            base.OnMouseLeave(e);
        }

        protected override void OnMouseDown(System.Windows.Forms.MouseEventArgs e)
        {
            m_bMouseDown = true;
            base.BackColor = Color.FromArgb(54, 54, 54);
            base.OnMouseDown(e);
        }

        protected override void OnMouseUp(System.Windows.Forms.MouseEventArgs e)
        {
            m_bMouseDown = false;
            base.OnMouseUp(e);
        }

        void m_SetDefaultState()
        {
            m_bHoverMode = false;
            m_bMouseDown = false;

            base.BackColor = Color.FromArgb(90,90,90);
            base.ForeColor = Color.FromArgb(254,254,254);
            base.Cursor = System.Windows.Forms.Cursors.Hand;
            base.Tag = "DEVBUTTON";
        }

    }
    public partial class ctrlDeviMainContainer : System.Windows.Forms.Panel
    {
        public ctrlDeviMainContainer()
        {
            base.BackColor = Color.FromArgb(62, 62, 62);
        }

        protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
        {            
            Pen penBorderInline = new Pen(Color.FromArgb(30,30,30), 1);            
            Rectangle rcButtonShapeInline = new Rectangle(1, 1, base.Width - 3, base.Height - 3);            
            e.Graphics.DrawRectangle(penBorderInline, rcButtonShapeInline);
            
            base.OnPaint(e);
        }

        protected override void OnResize(EventArgs eventargs)
        {
            base.Refresh();
            base.OnResize(eventargs);
        }

    }
    public partial class ctrlDeviButtonContainer : System.Windows.Forms.Panel
    {
        public ctrlDeviButtonContainer()
        {
            base.BackColor = Color.FromArgb(77,77,77);
        }

        protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
        {
            Pen penBorderOutline = new Pen(Color.FromArgb(30, 30, 30), 1);
            Pen penBorderInline = new Pen(Color.FromArgb(92,92,92), 1);

            Rectangle rcButtonShapeOutline = new Rectangle(0, 0, base.Width - 1, base.Height - 1);
            Rectangle rcButtonShapeInline = new Rectangle(1, 1, base.Width - 3, base.Height - 3);
            e.Graphics.DrawRectangle(penBorderOutline, rcButtonShapeOutline);
            e.Graphics.DrawRectangle(penBorderInline, rcButtonShapeInline);
            base.OnPaint(e);
        }

        protected override void OnResize(EventArgs eventargs)
        {
            base.Refresh();
            base.OnResize(eventargs);
        }
    }
    public partial class ctrlDeviLabel : System.Windows.Forms.Label
    {
        public ctrlDeviLabel()
        {

        }

        protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
        {
            Pen penUpperLine = new Pen(Color.FromArgb(92, 92, 92));
            Pen penLowerLine = new Pen(Color.FromArgb(31, 31, 31));

            Point[] ptLocation_A = new Point(base.Width - 1, base.Height - 1);
            e.Graphics.DrawLines(penUpperLine, ptLocation_A);
            
            base.OnPaint(e);
        }
        
    }

}
